/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bitoon.basketdudes.jpa;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author paco
 */
@Entity
@Table(name = "region", catalog = "basketdudes", schema = "central")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Region.findAll", query = "SELECT r FROM Region r"),
    @NamedQuery(name = "Region.findById", query = "SELECT r FROM Region r WHERE r.id = :id"),
    @NamedQuery(name = "Region.findByNombre", query = "SELECT r FROM Region r WHERE r.nombre = :nombre")})
public class Region implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Short id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "nombre")
    private String nombre;
    
    @ManyToOne
    @JoinColumn(name="partner_id", referencedColumnName = "id")
    private Partner partner;
    
/*    
    @OneToMany(mappedBy = "regionId")
    private Collection<RegionZona> regionZonaCollection;
*/
    public Region() {
    }

    public Region(Short id) {
        this.id = id;
    }

    public Region(Short id, String nombre) {
        this.id = id;
        this.nombre = nombre;
    }

    public Short getId() {
        return id;
    }

    public void setId(Short id) {
        this.id = id;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }
    
    public Partner getPartner() {
        return partner;
    }

    public void setPartner(Partner valor) {
        this.partner = valor;
    }
    
/*
    @XmlTransient
    public Collection<RegionZona> getRegionZonaCollection() {
        return regionZonaCollection;
    }

    public void setRegionZonaCollection(Collection<RegionZona> regionZonaCollection) {
        this.regionZonaCollection = regionZonaCollection;
    }
*/
    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Region)) {
            return false;
        }
        Region other = (Region) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bitoon.tres.jpa.Region[ id=" + id + " ]";
    }
    
}
